//
//  Singleton.h
//  03-23-PM-单例
//
//  Created by student on 16/3/23.
//  Copyright © 2016年 niit. All rights reserved.
//

#ifndef Singleton_h
#define Singleton_h

#define SingletonH(name) + (id)share##name;
#define SingletonM(name)\
static  id instance = nil;\
+(instancetype)allocWithZone:(struct _NSZone *)zone\
{\
    @synchronized(self) {\
        if (instance==nil) {\
            instance=[super allocWithZone:zone];\
        }\
    }\
    return instance;\
}\
+(instancetype)share##name\
{\
    @synchronized(self)\
    {\
        if (instance==nil) {\
            instance=[[self alloc]init];\
        }\
    }\
    \
    return instance;\
}\
- (id)copyWithZone:(nullable NSZone *)zone\
{\
    return instance;\
}\


#endif /* Singleton_h */
